<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>黔南民族师范学院综合教育学分认定系统</title>

    <link rel="stylesheet" href="/jquery-easyui-1.3.5/themes/icon.css" />
    <link rel="stylesheet" href="/jquery-easyui-1.3.5/themes/default/easyui.css"/>

    <script type="text/javascript" src="/jquery-easyui-1.3.5/jquery.min.js"></script>
    <script type="text/javascript" src="/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/jquery-easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" th:inline="none">
        $(function(){
            $('#dg').datagrid({
                url:'/class/queryAllClassGrades',
                striped:true,
                idField:'id',
                fitColumn:true,
                nowrap:true,
                pagination:true,
                pageSize:10,
                pageList:[10,15,20,25],
                toolbar: [{
                    iconCls: 'icon-add',
                    text:'添加班级',
                    handler: function(){
                        parent.$("#win").window({
                            title:"添加班级",
                            width:500,
                            height:320,
                            content:'<iframe src="/class/save" frameborder="0" width="100%" height="100%">'
                        });
                    }
                },'-',{
                    iconCls: 'icon-edit',
                    text:'更新班级',
                    handler: function(){
                        var rows = $("#dg").datagrid("getSelections");
                        if(rows.length != 1){
                            $.messager.show({
                                title:'错误提示',
                                msg:'请选中一条记录',
                                timeout:5000,
                                showType:'slide'
                            });
                        }else{
                            parent.$("#win").window({
                                title:"更新班级",
                                width:500,
                                height:320,
                                content:'<iframe src="/class/update" frameborder="0" width="100%" height="100%">'
                            });
                        }
                    }
                },'-',{
                    iconCls: 'icon-remove',
                    text:'删除班级',
                    handler: function(){
                        var rows = $("#dg").datagrid("getSelections");
                        if(rows.length != 1){
                            $.messager.show({
                                title:'错误提示',
                                msg:'请选择一条记录',
                                timeout:5000,
                                showType:'slide'
                            });
                        }else{
                            $.messager.confirm('删除确认对话框', '是否要删除选中的记录?', function(r){
                                if (r){
                                    var ids = "";
                                    for(var i=0;i<rows.length;i++){
                                        ids+=rows[i].id + ",";
                                    }
                                    ids=ids.substring(0, ids.lastIndexOf(","));
                                    $.post("/class/classGradeDelete",{ids:ids},function(result){
                                        if(result=="ok"){
                                            $("#dg").datagrid("reload");
                                            $("#dg").datagrid("uncheckAll");
                                        }else{
                                            $.messager.show({
                                                title:'删除异常',
                                                msg:'班级下存在学生，无法删除',
                                                timeout:2000,
                                                showType:'slide'
                                            });
                                        }
                                    });
                                }
                            });
                        }
                    }
                }
                ],

                columns:[[
                    {field:'check',checkbox:true},
                    {field:'id',title:'编号',width:50,align:'center'},
                    {field:'classCode',title:'班级代码',width:100,align:'center'},
                    {field:'className',title:'班级名称',width:100,align:'center'},
                    {field:'teachers',title:'（师范/非师范)',width:100,align:'center',
                        formatter:function(value,row,index){
                            if(value){
                                return "<input type='checkbox' checked='checked' disabled='disabled'>";
                            }else{
                                return "<input type='checkbox' disabled='true'>";
                            }
                        }
                    },
                    {field:'majorName',title:'所属专业',width:200,align:'center',
                    },
                    {field:'schoolName',title:'所属学院',width:200,align:'center',
                    },
                    {field:'truename',title:'所属辅导员',width:100,align:'center',
                    }
                ]]
            });

        });
    </script>
</head>

<body>
<table id="dg"></table>
</body>
</html>
